#include "QPropertyTreeView.h"

#include "QPropertyDelegate.h"
#include "QPropertyModel.h"

#include "private/QPropertyTreeView_p.h"

using namespace QPE;

QPropertyTreeView::QPropertyTreeView(QWidget *parent)
	: QTreeView(parent), d_ptr(new QPropertyTreeViewPrivate())
{
	init();
}

QPropertyTreeView::QPropertyTreeView(QPropertyModel *model, QWidget *parent)
	: QTreeView(parent), d_ptr(new QPropertyTreeViewPrivate())
{
	init();

	if(model)
		setModel(model);
}

QPropertyTreeView::QPropertyTreeView(QPropertyTreeViewPrivate *d, bool init_, QWidget *parent)
	: QTreeView(parent), d_ptr(d)
{
	if(init_)
		init();
}

QPropertyTreeView::~QPropertyTreeView()
{
	delete d_ptr;
}


void QPropertyTreeView::setRowHeight(int height, bool add_to_standard)
{
	d_ptr->PropertyDelegate->setRowHeight(height, add_to_standard);
}

void QPropertyTreeView::init()
{
	setAlternatingRowColors(true);
	setUniformRowHeights(true);
	d_ptr->PropertyDelegate = new QPropertyDelegate(this);
	setItemDelegate(d_ptr->PropertyDelegate);

	setSelectionMode(QTreeView::SingleSelection);
	setSelectionBehavior(QTreeView::SelectRows);
	setRootIsDecorated(true);

	setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::SelectedClicked);
}


